﻿using System.Globalization;
using JTLeigh.Commerce.Spencer.Core.Testing;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace JTLeigh.Commerce.Spencer.Core.Common.UnitTests
{

	/// <summary>
	/// Unit tests for the <see cref="CultureTools"/> class.
	/// </summary>
	[TestClass]
	public class CultureToolsFixture
	{

		#region Methods

        #region GetCultureName

        /// <summary>
        /// Ensures <see cref="CultureTools.GetCultureName"/> returns correct culture names.
        /// </summary>
        [TestMethod]
        public void TestGetCultureName()
        {
            Assert.AreEqual("en-CA", CultureTools.GetCultureName(CultureInfo.GetCultureInfo(TestConstants.CultureId.EnglishCanada).LCID));
            Assert.AreEqual("fr-CA", CultureTools.GetCultureName(CultureInfo.GetCultureInfo(TestConstants.CultureId.FrenchCanada).LCID));
        }

        #endregion // GetCultureName

        #region CompareCultureLanguages

        /// <summary>
		/// Ensures <see cref="CultureTools.CompareCultureLanguages"/> returns <see langword="true"/> 
		/// when called with the culture identifiers of two cultures that share a common language.
		/// </summary>
		[TestMethod]
		public void TestCompareCultureLanguagesWithCommonLanguage()
		{
			Assert.IsTrue(CultureTools.CompareCultureLanguages(TestConstants.CultureId.EnglishCanada, TestConstants.CultureId.EnglishUnitedStates));
			Assert.IsTrue(CultureTools.CompareCultureLanguages(TestConstants.CultureId.FrenchCanada, TestConstants.CultureId.FrenchFrance));
		}

		/// <summary>
		/// Ensures <see cref="CultureTools.CompareCultureLanguages"/> returns <see langword="false"/> 
		/// when called with the culture identifiers of two cultures that do not share a common 
		/// language.
		/// </summary>
		[TestMethod]
		public void TestCompareCultureLanguagesWithoutCommonLanguage()
		{
			Assert.IsFalse(CultureTools.CompareCultureLanguages(TestConstants.CultureId.EnglishCanada, TestConstants.CultureId.FrenchCanada));
			Assert.IsFalse(CultureTools.CompareCultureLanguages(TestConstants.CultureId.EnglishUnitedStates, TestConstants.CultureId.FrenchFrance));
		}

		#endregion // CompareCultureLanguages

		#endregion // Methods

	}

}
